package com.itheima.HomeWork;

import org.dom4j.Attribute;
import org.dom4j.Document;

import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.io.File;
import java.util.List;

public class Demo03 {
    public static void main(String[] args) throws Exception {
        SAXReader saxReader=new SAXReader();

        Document document=saxReader.read(new File("D:\\Idealgongcheng\\jn_68\\JavaAdvance\\JavaAdvance\\properties-xml-logback-app\\src\\com\\itheima\\HomeWork\\books.xml"));

        Element rootElement = document.getRootElement();
        List<Element> elements = rootElement.elements();


        for(Element element:elements){//每一个user Element
            Attribute id = element.attribute("id");
            System.out.println(id.getValue());

            Element name = element.element("name");
            System.out.println(name.getText());

            Element publish = element.element("publish");
            System.out.println(publish.getText());

            Element date = element.element("date");
            System.out.println(date.getText());

            Element price = element.element("price");
            System.out.println(price.getText());
        }
    }
}
